package com.faithbj.printer;

import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class RemoteInteractive {
	public static void testGet() throws IOException {
		 CloseableHttpClient httpclient = HttpClients.createDefault();
	        try {
	            HttpGet httpGet = new HttpGet("http://127.0.0.1:8080/simulation/index.jsp");
	            CloseableHttpResponse response1 = httpclient.execute(httpGet);
	            // The underlying HTTP connection is still held by the response object
	            // to allow the response content to be streamed directly from the network socket.
	            // In order to ensure correct deallocation of system resources
	            // the user MUST either fully consume the response content  or abort request
	            // execution by calling CloseableHttpResponse#close().

	            try {
	            	System.out.println("==================================");
	                System.out.println("status line: "+response1.getStatusLine());
	                System.out.println("==================================");
	                HttpEntity entity1 = response1.getEntity();
	                String html = EntityUtils.toString(entity1);
	                System.out.println("==================================");
	                System.out.println(html);
	                System.out.println("==================================");
	                EntityUtils.consume(entity1);
	            } finally {
	                response1.close();
	            }

	        } finally {
	            httpclient.close();
	        }
	}
	
	public static void testInsuranceQuery(){
		InsuranceConfirm ic = new InsuranceConfirm();
		try {
			String html = ic.insuranceQuery("11111111111111111111111");
			System.out.println(html);
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
		testInsuranceQuery();
	}
}
